package com.aw.guiguzi.module.manager._files

import com.aw.baselib.base.AwBaseBindingActivity
import com.aw.baselib.constants.Extras
import com.aw.baselib.util.AwDataUtil
import com.aw.baselib.util.AwFileUtil
import com.aw.baselib.util.download.DownloadResBean
import com.aw.guiguzi.databinding.ActivityManagerFileBrowseBinding

class FileBrowseActivity : AwBaseBindingActivity<ActivityManagerFileBrowseBinding?>() {
    private var mBean: DownloadResBean? = null
    override fun getViewBinding(): ActivityManagerFileBrowseBinding {
        return ActivityManagerFileBrowseBinding.inflate(layoutInflater)
    }

    override fun initData() {
        super.initData()
        mBean = intent.getSerializableExtra(Extras.params) as DownloadResBean?
        if (mBean == null) {
            showDialogToFinish("数据异常")
            return
        }
        setToolbar(mBean!!.fileName.replace("_guessapp.txt", ""), null)
        val content = AwFileUtil.loadFromSDFile(mBean!!.path)
        if (!AwDataUtil.isEmpty(content)) {
            showView(binding?.llContent, true)
            showView(binding?.viewNoData, false)
            setText(binding?.tvContent, content)
        } else {
            showView(binding?.llContent, false)
            showView(binding?.viewNoData, true)
        }
    }

    override fun initListener() {
        super.initListener()
    }
}